﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlogEngine.Core.Providers;

namespace BlogEngine.Core
{
    [Serializable]
    public class Coupon : BusinessBase<Coupon, Guid>, IComparable<Coupon>
    {
        #region Constants and Fields

        private string title;
        private string shop;
        private string link;
        private string endDate;
        private string number;
        private string password;
        private float amount;
        private string comment;

        public string Title
        {
            get { return title; }
            set { title = value; }
        }

        public string Shop
        {
            get { return shop; }
            set { shop = value; }
        }

        public string Link
        {
            get { return link; }
            set { link = value; }
        }

        public string EndDate
        {
            get { return endDate; }
            set { endDate = value; }
        }

        public string Number
        {
            get { return number; }
            set { number = value; }
        }

        public string Password
        {
            get { return password; }
            set { password = value; }
        }

        public float Amount
        {
            get { return amount; }
            set { amount = value; }
        }

        public string Comment
        {
            get { return comment; }
            set { comment = value; }
        }

        #endregion

        public int CompareTo(Coupon coupon)
        {
            if (coupon == null)
                return 1;

            return this.endDate.CompareTo(coupon.EndDate);
        }

        protected override void ValidationRules()
        {

        }

        protected override void DataUpdate()
        { }

        protected override Coupon DataSelect(Guid id)
        {
            return BlogService.SelectCoupon(id);
        }

        protected override void DataInsert()
        {
            BlogService.InsertCoupon(this);
        }

        protected override void DataDelete()
        {
            BlogService.DeleteCoupon(this);
        }

        public static List<Coupon> AllCoupon
        {
            get { return BlogService.FillCoupons(); }
        }
    }
}
